package com.ssm.controller;

import com.ssm.entity.ClassInfo;
import com.ssm.service.ClassInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RequestMapping(value = "classInfo")
@Controller
@CrossOrigin
public class ClassInfoController {
    @Autowired
    public ClassInfoService classInfoService;
    public void setClassInfoService(ClassInfoService classInfoService) {
        this.classInfoService = classInfoService;
    }

    @RequestMapping(value = "infos")
    @ResponseBody
    //RequestParam
    //PathVariable @RequestMapping(value = "infos/{address}")
    public List<ClassInfo> classInfoList(@RequestParam("address") String address){
        ClassInfo classInfo = this.classInfoService.queryClassInfo(address);
        List<ClassInfo> classInfos = new ArrayList<ClassInfo>();
        ClassInfo classInfo1 = new ClassInfo();
        classInfo1.setCourse_name("当前无课程");
        classInfo1.setGrade("当前无课程");
        classInfo1.setName("当前无课程");
        if (classInfos.size()==0){
            classInfos.add(classInfo1);
            return classInfos;
        }else {
            classInfos.add(classInfo);
            return classInfos;
        }

    }
}
